from django.contrib.auth.decorators import login_required


class LoginRequiredMixin(object):
    """login_required装饰器, 装饰类视图调用as_view()后的结果"""

    @classmethod
    def as_view(cls, **initkwargs):
        """重写as_view()"""

        # 获取类视图调用as_view()后的结果（得到一个view）
        view = super().as_view(**initkwargs)
        # login_required装饰器结果(view)
        return login_required(view)